﻿-var files = ViewData["files"] as IList<OrderFile>
-var resultFile = ViewData.ContainsKey("resultfile") ? ViewData["resultfile"] as OrderFile : null
-var versiondocs = ViewData.ContainsKey("versiondocs") ? ViewData["versiondocs"] as IList<OrderDocTemplate> : null
-var userversiondocs = ViewData.ContainsKey("userversiondocs") ? ViewData["userversiondocs"] as IList<OrderDocTemplate> : null
.filedataholder
  %table.orderinfo.data{width="100%",cellspacing="3"}
    %tr
      %td{width="18%"}
        %label
          %img.icon16{src="img/attach.gif"}
          Вложенные документы:
      %td{width="32%"}
        -if(files != null && files.Count() > 0)
          %ul#files.items
            -foreach( var file in files)
              -if(!file.IsDeleted)
                %li.file{id=string.Format("file{0}",file.Id)}
                  %img.icon16{src=string.Format("img/mime/{0}_16.gif",System.IO.Path.GetExtension(file.Name).TrimStart('.'))}
                  %a.noul{href=string.Format("order.ivp/viewfile/{0}",file.Id)}=file.Name
                  -if (!readOnly)
                    %a.noul{href="#",onclick=string.Format("return removeFile({0});",file.Id)}
                      %img{src="img/trash.gif",title="Удалить"}
                  .details=string.Format("({0}, {1})",file.User.FIO, file.Created.ToString("dd.MM.yyyy"))
        -else if (readOnly)
          ="отсутствуют"
        -if (!readOnly)
          .indent10
            %a.button{href="#",onclick="return attachFile()"}
              %img{src="img/addsmall.gif"}
              %span="Вложить документ"
        %div#addfiles
      %td{width="18%"}
        %label
          %img.icon16{src="img/attach.gif"}
          Документ, выданный клиенту:
      %td{width="32%"}
        -var isExists = (resultFile != null)
        #resultfileholder{class=(!isExists) ? "hidden" : ""}
          -if(isExists)
            %li.resultfile{id=string.Format("file{0}",resultFile.Id)}
              %img.icon16{src=string.Format("img/mime/{0}_16.gif",System.IO.Path.GetExtension(resultFile.Name).TrimStart('.'))}
              %a.noul{href=string.Format("order.ivp/viewfile/{0}",resultFile.Id)}=resultFile.Name
              -if (!readOnly)
                %a.noul{href="#",onclick=string.Format("return removeFile({0}, true);",resultFile.Id)}
                  %img{src="img/trash.gif",title="Удалить"}
              .details=string.Format("({0}, {1})", resultFile.User.FIO, resultFile.Created.ToString("dd.MM.yyyy"))
        -if (!isExists && readOnly)
          ="отсутствуют "
        #inputresultfileholder{class=(isExists || readOnly) ? "hidden" : ""}
          %input{size="30" type="file" id="resultfile" name="resultfile"}
  .divider
  %table.orderinfo.data{width="100%",cellspacing="3"}
    %tr
      %td{width="18%"}
        %label
          %img.icon16{src="img/attach.gif"}
          Шаблонные документы:
      %td{width="32%"}
        -if (versiondocs != null && versiondocs.Count() > 0)
          %ul#files.items
            -foreach(var file in versiondocs)
              %li.file{id=string.Format("file{0}",file.Id)}
                %img.icon16{src=string.Format("img/mime/{0}_16.gif",System.IO.Path.GetExtension(file.Name).TrimStart('.'))}
                -if (!readOnly && !versiondocs.Any(d => d.ParentId == file.Id))
                  %a.noul{href="#", onclick=string.Format("editDocTemplate({0},{1}); return false;", file.Id, entity.Id)}=file.Name
                -else
                  %a.noul{href=string.Format("order.ivp/viewversionfile/{0}",file.Id)}=file.Name
                .details=string.Format("({0})", file.CreateDate.ToString("dd.MM.yyyy"))
        -else
          ="отсутствуют"
      %td{width="18%"}
        %label
          %img.icon16{src="img/attach.gif"}
          Нешаблонные документы:
      %td{width="32%"}
        -if (userversiondocs != null && userversiondocs.Count() > 0)
          %ul#files.items
            -foreach(var file in userversiondocs)
              %li.file{id=string.Format("file{0}",file.Id)}
                %img.icon16{src=string.Format("img/mime/{0}_16.gif",System.IO.Path.GetExtension(file.Name).TrimStart('.'))}
                -if (!readOnly && !userversiondocs.Any(d => d.ParentId == file.Id))
                  %a.noul{href="#", onclick=string.Format("editDocTemplate({0},{1}); return false;", file.Id, entity.Id)}=file.Name
                -else
                  %a.noul{href=string.Format("order.ivp/viewversionfile/{0}",file.Id)}=file.Name
                .details=string.Format("({0})", file.CreateDate.ToString("dd.MM.yyyy"))
        -else if (readOnly)
          ="отсутствуют"
        -if (!readOnly)
          .indent10
            %a.button{href="#",onclick="return attachUserVersionFile()"}
              %img{src="img/addsmall.gif"}
              %span="Вложить документ"
        %div#adduserversionfiles					